package cn.com.qing.mydb.dbhelp;


import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * get path MyResource
 * @author qing
 * @version 1.0.0
 *
 */
public class MyResource {
	private static MyResource classLoaderWrapper = new MyResource();
	
	/**
	 * get Properties
	 * @param resource src file path name
	 * @return Properties
	 */
	public static Properties getResourceAsProperties(String resource){
		try {
			Properties props = new Properties();
			InputStream in = classLoaderWrapper.getClass().getResourceAsStream(resource);
			props.load(in);
			in.close();
			return props;
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	/**
	 * InputStream get file Stream
	 * @param resource src file path name
	 * @return InputStream
	 */
	public static InputStream getResourceAsInputStream(String resource){
		try{
			InputStream in = classLoaderWrapper.getClass().getResourceAsStream(resource);
			return in;
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
